package org.qiyu.live.im.provider;

import jakarta.annotation.Resource;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.qiyu.live.im.constants.AppIdEnums;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.qiyu.live.im.provider.service.ImOnlineService;

@SpringBootApplication
@EnableDiscoveryClient // 服务注册
@EnableDubbo
public class ImProviderApplication implements CommandLineRunner {

    @Resource
    private ImOnlineService onlineService;

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(ImProviderApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.SERVLET);
        springApplication.run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        long userId = 10001L;
        // imCoreServerIp:10001:10001

        int code = AppIdEnums.QIYU_LIVE_BIZ.getCode();
        for(int i = 0; i < 10;++i) {
            boolean online = onlineService.isOnline(userId + i, code);
            System.out.println(online);
        }
    }
}